package com.bloody.android.Map;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;

import com.bloody.android.R;
import com.bloody.android.ViewObject;

public abstract class ViewCase extends ViewObject {
	
	private Case c;
	private Bitmap red;
	private Drawable tileRed;
	
	public ViewCase(Context context, Case c, int id){
		super(context, id);
		this.c = c;

		tileRed = DrawableCaseFactory.getDrawable(R.drawable.rouge, context);
	}
	
	public int getPosx(){
		return c.getPosx();
	}
	
	public int getPosy(){
		return c.getPosy();
	}
	
	public void createIm(int tileSize){
		super.createIm(tileSize);

        red = Bitmap.createBitmap(tileSize, tileSize, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(red);
        tileRed.setBounds(0, 0, tileSize, tileSize);
        tileRed.draw(canvas);
	}
	
	public void draw(Canvas canvas, int mXOffset, int mYOffset, int mTileSize, Paint mPaint, int xmin, 
			int xmax, int ymin, int ymax){
		
		int posx = getPosx();
		int posy = getPosy();
		
		if(posx>=xmin && posx<=xmax && posy>=ymin && posy<=ymax){
			super.draw(canvas, mXOffset, mYOffset, mTileSize, mPaint, xmin, xmax, ymin, ymax);
			if (c.isCheck())
				super.draw(red, canvas, mXOffset, mYOffset, mTileSize, mPaint, xmin, xmax, ymin, ymax);			
		}
	}
}
